/*
 * Core Routines MC9S08SH8
 * core.h
 *
 * Created on: 12/04/2011
 * Author: Leandro Perez Guatibonza
 */

/*
 * Include Section
 */
#include <hidef.h>      // EnableInterrupts macro
#include "derivative.h" // Peripheral declarations

#ifndef CORE_H
#define CORE_H

/*
 * Typedef Section
 */
typedef unsigned char byte;
typedef unsigned int word;

/*
 * Constant Core Section
 */
#define LOW = 0;
#define HIGH = 1;

#define false = 0;
#define true = 1;

/*
 * Constant Input/Output Section
 */

#define PIN_INTERRUPT_EDGE = 0;
#define PIN_INTERRUPT_EDGE_LEVEL = 1;

#define PIN_INTERRUPT_FALLING_LOW = 0;
#define PIN_INTERRUPT_RISING_HIGH = 1;

/*
 * Function Input/Output Section
 */

// Pin configured as output
void pinConfigureOutput(unsigned char port, unsigned char pinNumber);

// Pin configured as input
void pinConfigureInput(unsigned char port, unsigned char pinNumber);

// Read the status of a pin
unsigned char pinRead(unsigned char port, unsigned char pinNumber);

// Send a state to a pin
void pinWrite(unsigned char port, unsigned char pinNumber, unsigned char level);

// Set a Pull-Up on a pin
void pinConfigurePullUp(unsigned char port, unsigned char pinNumber);

// Configure Slew Rate on a pin
void pinConfigureSlewRate(unsigned char port, unsigned char pinNumber);

// Configure a Drive Strength on a pin
void pinConfigureDriveStrength(unsigned char port, unsigned char pinNumber);

// Enable the interrupt on a pin
void pinEnablePinInterrupt(unsigned char port, unsigned char pinNumber, unsigned char mode);

// Enable the interrupt on a pin
void pinDisablePinInterrupt(unsigned char port, unsigned char pinNumber);

// Enable pin interrupts
void pinEnableInterrupts(unsigned char mode);

// Disable pin interrupts
void pinDisableInterrupts();

/*
 * Function Time Section
 */

// Generates a delay in milliseconds
void delayMilliseconds(unsigned char valueDelay);

// Generates a delay in milliseconds
void delaySeconds(unsigned char valueDelay);

#endif /* CORE_H_ */
